package ar.uade.fain.ai.tpo.view.seccion;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import ar.uade.fain.ai.tpo.Sistema;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class EliminarSeccion extends javax.swing.JFrame {
	
	private static final long serialVersionUID = 1L;
	
	private JButton eliminarButton;
	private JTextField idText;
	private JTextField mensajeText;
	private JLabel idLabel;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				EliminarSeccion inst = new EliminarSeccion();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public EliminarSeccion() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				eliminarButton = new JButton();
				eliminarButton.setLayout(null);
				getContentPane().add(eliminarButton, BorderLayout.CENTER);
				eliminarButton.setText("Eliminar");
				eliminarButton.setBounds(77, 78, 148, 24);
				eliminarButton.addActionListener(new ActionListener() {
					@Override
					public void actionPerformed(ActionEvent e) {
						if (!idText.getText().isEmpty()) {
							try {
								Sistema.get().getSeccionControlador()
									.eliminarSeccion(Long.valueOf(idText.getText()));
								mensajeText.setText("Hecho.");
							} catch (Exception ex) {
								mensajeText.setText("Hubo un problema.");
							}
						}
					}
				});
			}
			{
				idText = new JTextField();
				getContentPane().add(idText);
				idText.setBounds(165, 25, 103, 22);
			}
			{
				idLabel = new JLabel();
				getContentPane().add(idLabel);
				idLabel.setText("ID de la seccion:");
				idLabel.setBounds(36, 28, 131, 15);
			}
			{
				mensajeText = new JTextField();
				getContentPane().add(mensajeText);
				mensajeText.setBounds(77, 107, 148, 22);
			}
			pack();
			this.setSize(308, 179);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
